package com.hingstd.lastwork.controllers;

import com.hingstd.lastwork.dao.ArticleRepository;
import com.hingstd.lastwork.dao.CommentRepository;
import com.hingstd.lastwork.entities.Article;
import com.hingstd.lastwork.entities.Comment;
import com.hingstd.lastwork.services.ArticleService;
import com.hingstd.lastwork.services.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class HomeController {

    @Autowired
    ArticleService articleService;

    @Autowired
    CommentService commentService;

    @GetMapping("/classification1")
    public String displayHome(Model model){

        List<Article> articles = articleService.getAll();
        model.addAttribute("articles",articles);

        List<Comment> comments = commentService.getAll();
        model.addAttribute("comments",comments);
        return "classification1";

    }

}
